﻿using MediatR;
using System.WXT.Infrstructre.Interface;
using System.WXT.WebAPI.Application.Command.WorkerCommand;

namespace System.WXT.WebAPI.Application.CommandHandlers.WorkerCommandHandlers
{
    public class WorkerUpdateStateCommandHandlers:IRequestHandler<WorkerUpdateStateCommand,int>
    {
        protected readonly IWorkerRepository workerRepository;

        public WorkerUpdateStateCommandHandlers(IWorkerRepository workerRepository)
        {
            this.workerRepository = workerRepository;
        }
        /// <summary>
        /// 工人修改状态
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(WorkerUpdateStateCommand request, CancellationToken cancellationToken)
        {
            var list = await workerRepository.GetBaby(request.workerId);
            list.workerState = "离职";
            return await workerRepository.Update(list);
        }
    }
}
